package com.example.testlzhu

import android.content.Context
import android.util.Log
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import java.util.*


/**
 * @ClassName: FlutterGetuuidPlugin
 * @Description: java类作用描述
 * @Author: zdl
 * @Date: 2021/12/8 15:27
 */
class FlutterGetuuidPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {


    companion object {
        const val CHANNEL = "com.example.jump/plugin"

        /** Plugin registration.  */
        fun registerWith(flutterEngine: FlutterEngine?) {

            flutterEngine?.plugins?.add(FlutterGetuuidPlugin())
        }


    }

    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
//接收来自flutter的指令oneAct
        //接收来自flutter的指令oneAct
        if (call.method.equals("getUid")) {
            val replace = UUID.randomUUID().toString().replace("-", "")
            result.success(replace)
        }
    }


    lateinit var channel: MethodChannel
    override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
        channel = MethodChannel(binding.binaryMessenger, CHANNEL)
        channel.setMethodCallHandler(this)
    }

    override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
        channel.setMethodCallHandler(null)
    }


}